
<!--
<template>
   首页
&lt;!&ndash;  <router-view/>&ndash;&gt;
</template>
<script setup>

</script>

<style scoped>
</style>-->
<!--
<template>
   首页
&lt;!&ndash;  <router-view/>&ndash;&gt;
</template>
<script setup>
</script>
<style scoped>
</style>-->
<script setup>
// 审批
import { ref } from 'vue';
import { ElTabs, ElTabPane, ElButton } from 'element-plus';
import router from "@/router";

const activeTab = ref('pending');
const pendingApprovals = ref([
  { id: 1, name: '审批事项1' },
  { id: 2, name: '审批事项2' },
  // 更多待审批数据...
]);
const completedApprovals = ref([
  { id: 3, name: '已办事项1' },
  { id: 4, name: '已办事项2' },
  // 更多已办数据...
]);

const handleApprove = (item) => {
  // 处理审批逻辑
  console.log('办理审批:', item);
  // 可以在这里添加路由跳转或模态框显示
  router.push('/my/mycheck/check');
};

const handleView = (item) => {
  // 处理查看逻辑
  console.log('查看已办:', item);
  // 可以在这里添加路由跳转或模态框显示
  router.push('/my/mycheck/checkdone');
};

const handleTabClick = (tab) => {
  console.log('点击了标签页:', tab);
};

const goToMore = (tab) => {
  // 跳转到更多页面的逻辑
  console.log('跳转到更多', tab);
  // 可以在这里添加路由跳转
  router.push('/my/mycheck/check');
};




// 任务通告
import {  computed } from 'vue';
import { ElTable, ElTableColumn, ElDialog } from 'element-plus';
import { useStore } from 'vuex';
const store = useStore();
const messages = ref([
  // 消息列表数据
]);
const selectedMessage = ref({});
const isDialogVisible = ref(false);
const replyMessage = ref('');

const sortedMessages = computed(() => {
  return messages.value.sort((a, b) => new Date(b.date) - new Date(a.date));
});

const viewMessage = (row) => {
  selectedMessage.value = row;
  isDialogVisible.value = true;
  // 标记为已读
  store.commit('markAsRead', row.id);
};

const sendReply = () => {
  // 发送回复
  console.log('发送回复:', replyMessage.value);
  // 这里可以调用 API 发送回复
  alert('回复成功');
};

const goToMessages = () => {
  // 跳转到消息列表页面
  console.log('跳转到消息列表');
  router.push('/dailyman/noticeMan/noticeman');
};



// 我的任务
const isPanelOpen = ref(false); // 控制面板显示的状态
const tasks = ref([
  { id: 1, name: '单据1' },
  { id: 2, name: '单据2' },
  { id: 3, name: '单据3' },
  // 更多单据...
]);

const togglePanel = () => {
  isPanelOpen.value = !isPanelOpen.value;
};


const selectTask = (task) => {
  console.log('选中的任务:', task);
  // 处理选中任务的逻辑...
  //跳转到单据页面
  router.push('/my/documentselect')
  isPanelOpen.value = false; // 选中任务后关闭面板
};

</script>

<template>
  <div class="main-container">
    <!--    <div class="content">
          &lt;!&ndash; 其他内容 &ndash;&gt;
        </div>-->
    <!--    我的任务-->
    <div class="content">
      <div class="header" @click="togglePanel">
        我的任务
        <button class="toggle-button">
          <span v-if="!isPanelOpen">+</span>
          <span v-if="isPanelOpen">-</span>
        </button>
      </div>
      <div class="panel" v-if="isPanelOpen">
        <ul>
          <li v-for="item in tasks" :key="item.id" @click="selectTask(item)">
            {{ item.name }}
          </li>
        </ul>
      </div>

    </div>


    <!--    我的审批-->
    <div class="approval-panel">
      <el-tabs v-model="activeTab" @tab-click="handleTabClick">
        <el-tab-pane label="审批" name="pending">
          <div class="approval-list">
            <div v-for="item in pendingApprovals" :key="item.id" class="approval-item">
              <el-button type="text" @click="handleApprove(item)">办理</el-button>
              {{ item.name }}
            </div>
            <el-button type="primary" class="more-btn" @click="goToMore('pending')">更多</el-button>
          </div>
        </el-tab-pane>
        <el-tab-pane label="已办" name="completed">
          <div class="completed-list">
            <div v-for="item in completedApprovals" :key="item.id" class="approval-item">
              <el-button type="text" @click="handleView(item)">查看</el-button>
              {{ item.name }}
            </div>
            <el-button type="primary" class="more-btn" @click="goToMore('completed')">更多</el-button>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>



  <!--任务通告-->
  <div class="message-panel">
    <h2>任务通告</h2>
    <el-table :data="sortedMessages" @row-click="viewMessage">
      <el-table-column prop="title" label="标题"></el-table-column>
      <el-table-column prop="date" label="日期"></el-table-column>
      <el-table-column prop="status" label="状态"></el-table-column>
    </el-table>
    <el-button type="primary" @click="goToMessages">更多</el-button>

    <!-- 消息详情对话框 -->
    <el-dialog :visible.sync="isDialogVisible" title="消息详情">
      <div>
        <h3>{{ selectedMessage.title }}</h3>
        <p>{{ selectedMessage.content }}</p>
        <div v-if="selectedMessage.replyType === '回复已读'">
          <el-input v-model="replyMessage" placeholder="请输入回复内容"></el-input>
          <el-button type="primary" @click="sendReply">发送</el-button>
        </div>
        <p v-if="selectedMessage.reply">回复: {{ selectedMessage.reply }}</p>
      </div>
    </el-dialog>
  </div>

</template>


<style scoped>
/*.approval-panel {
  max-width: 400px;
  margin: 20px;
}

.approval-list, .completed-list {
  margin-top: 20px;
}

.approval-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.more-btn {
  display: block;
  margin-top: 20px;
}*/
/*审批样式*/
.main-container {
  position: relative;
  min-height: 100vh; /* 确保父容器足够高  上半部分总的 */


}

.content {
  margin-right: 460px; /* 为右侧面板留出空间 */
                       /*属于左边我的任务样式*/
}

.approval-panel {
  position: absolute;
  top: 0;
  right: 9px;
  width: 400px;     /*子容器  属于我的审批样式*/
  height: 38vh; /* 使面板高度与视口高度相同 */
  overflow-y: auto; /* 允许内容滚动 */
}




.approval-panel {
  max-width: 800px;
  margin: 10px auto;
  padding: 20px;
  background-color: rgba(252, 252, 252, 0.85);
  border-radius: 8px;
  box-shadow: 0 4px 8px rgb(220, 255, 242);
}

.approval-list,
.completed-list {
  margin-top: 20px;
}

.approval-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px;
  background-color: #dcfff2;
  border-radius: 4px;
  transition: background-color 0.3s;
}

.approval-item:hover {
  background-color: #e9e9e9;
}

.more-btn {
  margin-top: 20px;
  display: block;
  width: 100%;
}

/* 动画 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s;
}
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}




/*.message-panel {
  max-width: 600px;
  margin: 1px auto;
}

.el-table {
  margin-top: 20px;
}*/
/*任务通告样式*/
.message-panel {
  transform: translateY(-170px); /* 向上移动20px */
}

/*我的任务样式*/
.content {
  padding: 20px;
  background-color: rgb(220, 255, 242);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgb(220, 255, 231);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  cursor: pointer;
  background-color: rgba(220, 255, 231, 0.53);
  border-bottom: 1px solid rgb(255, 255, 255);
}

.toggle-button {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
}

.panel {
  padding: 0 10px;
}

ul {
  list-style: none;
  padding: 0;
}

li {
  padding: 10px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background-color 0.3s;
}

li:hover {
  background-color: #f5f5f5;
}

.fade-enter-active, .fade-leave-active {
  transition: max-height 0.5s ease, opacity 0.5s ease;
}

.fade-enter-from, .fade-leave-to {
  max-height: 0;
  opacity: 0;
}
</style>